package com.kpmg.datalake.common.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.kpmg.datalake.common.service.ProjectManagementService;
import com.kpmg.datalake.common.vo.ProjectVO;
import com.kpmg.datalake.common.vo.ServerResponse;
import com.kpmg.datalake.db.model.Project;
import com.kpmg.datalake.operatelog.annotation.OptLog;
import com.kpmg.datalake.operatelog.enums.LogTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.kpmg.datalake.common.vo.ProjectEntityVO;

/**
 * <p> 项目基础信息 前端控制器 </p>
 *
 * @author azhao6
 * @since 2018-08-17
 */
@RestController
@RequestMapping("/project")
public class ProjectController extends BaseController {

  @Autowired
  ProjectManagementService projectManagementService;

  @PostMapping("/getProjectInfo")
  public ServerResponse<Page<Project>> getProjectInfoList(@RequestBody ProjectVO projectVO) {
    return projectManagementService.getProjectList(projectVO);
  }

  @PostMapping("/saveProject")
  @OptLog(logType = LogTypeEnum.OPERATION, module = "system", description = "操作项目")
  public ServerResponse<String> saveProject(@RequestBody ProjectEntityVO projectEntityVO ) {
    return projectManagementService.saveProjectEnt(projectEntityVO.getProject(),projectEntityVO.getEntity());
  }

  @PostMapping("/testSftp")
  public ServerResponse<String> testSftp(@RequestBody ProjectEntityVO projectEntityVO ) {
    return projectManagementService.testSftp(projectEntityVO.getProject());
  }
  @PostMapping("/sysProject")
  public ServerResponse<String> sysProject(@RequestBody ProjectEntityVO projectEntityVO ) {
    return projectManagementService.sysProject(projectEntityVO.getProject());
  }
}
